package com.neusoft.controller;

import com.neusoft.po.CommonResult;
import com.neusoft.po.EfficientCreditVo;
import com.neusoft.po.ExpiredCreditVo;
import com.neusoft.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/plus/CreditController")
@RefreshScope
public class CreditController {

	@Autowired
	private ScoreService scoreService;

	@PostMapping("/listScoreByUserId")
	public CommonResult<List> listScoreByUserId(@RequestParam("userId") String userId) {
		List<Score> i = scoreService.listScoreByUserId(userId);
		return new CommonResult(200, "success", i);
	}

	@PostMapping("/getAllScore")
	public CommonResult<List> getAllScore(@RequestParam("userId") String userId) {
		int i = scoreService.getAllScore(userId);
		System.out.println("UserId: " + userId + ", Total Score: " + totalScore);
		return new CommonResult(200, "success", i);
	}

	@PostMapping("/removeScore")
	public CommonResult<List> removeScore(@RequestParam("scoredId") Integer scoreId) {
		int i=scoreService.removeScore(scoreId);
		return new CommonResult(200, "success", i);
	}

	@PostMapping("/createScore")
	public CommonResult<List> createScore(@RequestParam("score") Score score) {
		int i=scoreService.createScore(scoreId);
		return new CommonResult(200, "success", i);
	}

	@PostMapping("/useScore")
	public CommonResult<List> useScore(@RequestParam("orderId") Integer orderId, @RequestParam("usedScore") Integer usedScore) {
		int i=scoreService.useScore(orderId,usedScore);
		return new CommonResult(200, "success", i);
	}
}
